package com.upb.webserver.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;


@Getter
@ToString
@AllArgsConstructor
@Slf4j
public enum NodeTypeEnum {
    FISCO_CONSENSUS(0, "fisco共识节点"),
    FISCO_FREE(1, "fisco游离节点"),
    FISCO_OBSERVED(2, "fisco观察节点"),
    FABRIC_PEER(3, "fabric的peer节点"),
    FABRIC_ORDERER(4, "fabric的order节点"),
    FABRIC_CA(5, "fabric的ca节点");

    private byte id;
    private String description;

    NodeTypeEnum(int id, String description) {
        this.id = (byte) id;
        this.description = description;
    }

    /**
     * @param id
     * @return
     */
    public static NodeTypeEnum getById(byte id) {
        for (NodeTypeEnum value : NodeTypeEnum.values()) {
            if (value.id == id) {
                return value;
            }
        }
        return null;
    }

    public byte getId() {
        return this.id;
    }
}
